package com.oa.jixiao.dao;

import com.oa.jixiao.entity.Attendance;
import com.oa.jixiao.entity.EmpVO;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.mybatis.spring.annotation.MapperScan;

@MapperScan
public interface AttendanceMapper {
    @Delete({
        "delete from oa_atd",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into oa_atd (id, emp_num, ",
        "atd_am, atd_pm, ",
        "atd_date)",
        "values (#{id,jdbcType=INTEGER}, #{empNum,jdbcType=VARCHAR}, ",
        "#{atdAm,jdbcType=VARCHAR}, #{atdPm,jdbcType=VARCHAR}, ",
        "#{atdDate})"
    })
    int insert(Attendance record);

    int insertSelective(Attendance record);

    @Select({
        "select",
        "id, emp_num, atd_am, atd_pm, atd_date",
        "from oa_atd",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("com.oa.jixiao.dao.AttendanceMapper.BaseResultMap")
    Attendance selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(Attendance record);

    @Update({
        "update oa_atd",
        "set emp_num = #{empNum,jdbcType=VARCHAR},",
          "atd_am = #{atdAm,jdbcType=VARCHAR},",
          "atd_pm = #{atdPm,jdbcType=VARCHAR},",
          "atd_date = #{atdDate}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Attendance record);
    @Update({
        "update oa_atd",
        "set atd_pm = #{atdPm,jdbcType=VARCHAR}",
        "where emp_num = #{empNum} and atd_date=#{atdDate}"
    })
    int update(Attendance record);
    
    @Select("select count(id) from oa_atd where emp_num = #{empNum} and atd_date=#{atdDate} ")
    int find(Attendance record);
    
    
    @ResultMap("com.oa.jixiao.dao.AttendanceMapper.BaseResultMap")
    @Select("select * from oa_atd where atd_date between #{startime} and #{endtime}")
    List<Attendance> findAllByTiME(EmpVO empVO);
    

    @ResultMap("com.oa.jixiao.dao.AttendanceMapper.BaseResultMap")
    @Select("select * from oa_atd where emp_num=#{number} and atd_date between #{startime} and #{endtime}")
    List<Attendance> findAllByTiMEAndNum(EmpVO empVo);
}